<?php

namespace api\modules\backend\models;

use Yii;
use \yii\db\ActiveRecord;

/**
 * Restaurant Model
 *
 * @author Fong <xiaofeng.zhang@suppernovachina.com>
 */
class Restaurant extends ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%restaurant}}';
    }

    /**
     * @inheritdoc
     */
    public static function primaryKey()
    {
        return ['restaurant_id'];
    }

    /**
     * Define rules for validation
     */
    public function rules()
    {
        return [
            [['restaurant_name', 'restaurant_address', 'restaurant_contact', 'active'], 'required'],
            [['restaurant_name'], 'string', 'length' => [2, 20]],
            [['restaurant_name'], 'unique'],
            [['active'], 'in', 'range' => [0, 1]]
        ];
    }
}
